import Vue from 'vue'
import App from './App'
import axios from "axios";
import less from 'less'
import router from './router'
import Element from 'element-ui'
import TreeTable from 'vue-table-with-tree-grid'
import 'element-ui/lib/theme-chalk/index.css'
// 右边就是你后端的每个请求地址公共的部分
//导入全局样式表
import './assets/css/global.css'
// 导入iconfont图标
import './assets/fonts/iconfont.css'
// 导入富文本编辑器
import  VueQuillEditor  from 'vue-quill-editor'
//一定要引入这三个css，不然文本编辑器会出现不规则黑白几何图形
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

// 导入NProgress, 包对应的JS和CSS
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'



Vue.prototype.$http=axios;  // 修改内部的$http为axios vue内部为http的异步
Vue.config.productionTip = false
// 配置请求的根路径
axios.defaults.baseURL = 'https://www.liulongbin.top:8888/api/private/v1/'
// axios.defaults.baseURL = 'http://timemeetyou.com:8889/api/private/v1/'
// 需要授权的 API ，必须在请求头中使用 `Authorization` 字段提供 `token` 令牌
axios.interceptors.request.use(config => {
  console.log(config)
  Nprogress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 在最后必须 return config
  return config
})
// response 拦截器中,  隐藏进度条NProgress.done()
axios.interceptors.response.use(config => {
  Nprogress.done()
  return config
});
// response 拦截器中,  隐藏进度条NProgress.done()
axios.interceptors.response.use(config => {
  Nprogress.done();
  return config;
});


Vue.use(router);
Vue.use(less);
Vue.use(Element);
// 将富文本注册成全局可用的组件
Vue.use(VueQuillEditor)
Vue.component('tree-table',TreeTable)

// 时间得全局过滤器 毫秒转化
Vue.filter('dateFormat', function (originVal) {
  const date = new Date(originVal)

  const y = date.getFullYear();
  const m = (date.getMonth() + 1 + '').padStart(2, '0')
  const d = (date.getDate() + '').padStart(2, '0')

  const hh = (date.getHours() + '').padStart(2, '0')
  const mm = (date.getMinutes() + '').padStart(2, '0')
  const ss = (date.getSeconds() + '').padStart(2, '0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App),

})


